//
//  SHA1Secret.m
//  TenThousand
//
//  Created by 我的 on 16/6/27.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "SHA1Secret.h"
#include <CommonCrypto/CommonDigest.h>

@implementation SHA1Secret

+ (NSString *)getKeyWithActionName:(NSString *)actionName
{
    
    
//    actionName = [actionName stringByAppendingString:@"*(Wyf%%fyW)*"];
    const char *cstr = [actionName cStringUsingEncoding:NSUTF8StringEncoding];
    NSData *data = [NSData dataWithBytes:cstr length:actionName.length];
    
    uint8_t digest[CC_SHA1_DIGEST_LENGTH];
    
    CC_SHA1(data.bytes, (int)data.length, digest);
    
    NSMutableString *output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
    
    for(int i=0; i<CC_SHA1_DIGEST_LENGTH; i++) {
        [output appendFormat:@"%02x", digest[i]];
    }
    return [output uppercaseString];
    
    


}

@end
